var app = getApp();
Page({
    data:{
        siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;
        var zfid = options.zfid ? options.zfid : ( options.scene ? options.scene : 0 );
        self.setData({
            options : options,
        });
        var postdata = {
            zfid : zfid,
            op : 'applyinfo',
            type : options.type ? options.type : '',
        }
        app.com.auth(function(user){
            app.com.http('ucard','POST',postdata,0,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        params : res.data.data.params,
                        userinfo : res.data.data.userinfo,
                        inited : true,
                    });
                }else{
                    app.com.alert(res.data.message);
                }
            });
        });

        wx.setNavigationBarTitle({
            title:  '申请会员',
        });
    },
    submit(e){
        var self = this;
        var postdata = {
            op : 'subapply',
            name : e.detail.value.name,
            tel : e.detail.value.phone,
            formId : e.detail.formId,
            type : self.data.options.type ? self.data.options.type : '',
        };
        if( postdata.name == '' ){
            app.com.alert('请填写姓名');
            return false;
        }
        if( postdata.tel == '' ){
            app.com.alert('请填写电话');
            return false;
        }

        app.com.http('ucard','POST',postdata,0,true,'','',function(res){
            if (!res.data.errno && res.data ) {
                app.com.alert(res.data.message,function(){
                    wx.navigateBack({delta:2});
                });
            }else{
                app.com.alert(res.data.message);
            }
        });

    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})